import './SignA01.scss'
import { useState } from 'react'
import { Button, Form, Input } from 'antd'
import { LockOutlined, UserOutlined } from '@ant-design/icons'
import { ModelBox } from '../../Model'
import { useMount } from 'ahooks'


import { useLocation } from 'react-router-dom'

const { port } = window.location
const SignUpA01 = ({ btnText }) => {
    const [Loading, setLoading] = useState(false)
    const [OptionsCall, setOptionsCall] = useState()

    const { search } = useLocation()
    const onFinish = (e) => setOptionsCall({ type: 'SignUpLoading', title: '正在登录...', close: true, width: 400, data: e })

    useMount(() => {
        if (search) onFinish()
    })


    return (
        <Form
            name="normal_login"
            className="SignUp"
            initialValues={{ username: port ? '18745058051' : '', password: port ? '123456' : '' }}
            onFinish={onFinish}
        >
            <Form.Item name="username" rules={[{ required: true, message: '请输入登录账户!' }]}>
                <Input prefix={<UserOutlined className="site-form-item-icon" />} placeholder="登录账户" disabled={Loading} />
            </Form.Item>
            <Form.Item name="password" rules={[{ required: true, message: '请输入登录密码!' }]}>
                <Input.Password prefix={<LockOutlined className="site-form-item-icon" />} placeholder="登录密码" disabled={Loading} />
            </Form.Item>
            <Form.Item>
                <Button htmlType="submit" size='large' shape="round" className="SignUp" loading={Loading}>{btnText}</Button>
            </Form.Item>
            <ModelBox OptionsCall={OptionsCall} />
        </Form>
    );
};

export default SignUpA01;